<html>
<head><meta charset="utf-8"><title>static_assert for const generics · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html">static_assert for const generics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228063709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063709">(Feb 27 2021 at 15:11)</a>:</h4>
<p>In <code>stdarch</code> I need to place certain restrictions on const generics before passing them on to LLVM intrinsics otherwise LLVM will ICE. For example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">vsri_n_s8</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">n</span>: <span class="kt">i32</span><span class="o">&gt;</span><span class="p">(</span><span class="n">a</span>: <span class="nc">int8x8_t</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="nc">int8x8_t</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">int8x8_t</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">static_assert</span><span class="o">!</span><span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">n</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="mi">7</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">vsli_n_s8_</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228063780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063780">(Feb 27 2021 at 15:12)</a>:</h4>
<p>Using a normal <code>assert!</code> is not enough: the problem is that the intrinsic call still reaches LLVM codegen with an invalid immediate argument, even though it is unreachable. This causes an ICE.</p>



<a name="228063795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063795">(Feb 27 2021 at 15:12)</a>:</h4>
<p>I need some way of preventing invalid values from reaching LLVM codegen entirely.</p>



<a name="228063798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063798">(Feb 27 2021 at 15:12)</a>:</h4>
<p>this would have been slightly more fitting in <a class="stream" data-stream-id="260443" href="/#narrow/stream/260443-project-const-generics">#project-const-generics</a> ^^</p>



<a name="228063799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063799">(Feb 27 2021 at 15:12)</a>:</h4>
<p>but</p>



<a name="228063806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063806">(Feb 27 2021 at 15:12)</a>:</h4>
<p>we're working on bounds for this with <code>feature(const_evaluatable_checked)</code></p>



<a name="228063812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063812">(Feb 27 2021 at 15:12)</a>:</h4>
<p>that's still quite far from being stable though</p>



<a name="228063820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063820">(Feb 27 2021 at 15:13)</a>:</h4>
<p>so i don't recommend using it in anything serious yet</p>



<a name="228063849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063849">(Feb 27 2021 at 15:13)</a>:</h4>
<p>I'd be happy with any kind of post-monomorphization error here.</p>



<a name="228063850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063850">(Feb 27 2021 at 15:13)</a>:</h4>
<p>considering that the range is fairly small, you can use <code>LengthAtMost32</code>hack</p>



<a name="228063918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063918">(Feb 27 2021 at 15:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="143274">Amanieu</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228063849">said</a>:</p>
<blockquote>
<p>I'd be happy with any kind of post-monomorphization error here.</p>
</blockquote>
<p>if you use a <code>const</code> in a fn that fails to evaluate, that will post-monomorphize-error and codegen will not happen</p>



<a name="228063926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063926">(Feb 27 2021 at 15:14)</a>:</h4>
<p>yeah, you could also use an assoc const in that fn</p>



<a name="228063947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063947">(Feb 27 2021 at 15:15)</a>:</h4>
<p>because associated consts are the only constants which are allowed to use generic params</p>



<a name="228063971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228063971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228063971">(Feb 27 2021 at 15:15)</a>:</h4>
<p>yeah... this brings us back to the discussion about whether or not <code>const {...}</code> should be more like assoc consts or somehow prevent post-mono errors ;)</p>



<a name="228064038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064038">(Feb 27 2021 at 15:16)</a>:</h4>
<p>How would that code look like?</p>



<a name="228064039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064039">(Feb 27 2021 at 15:16)</a>:</h4>
<p>imo we should prevent post-mono errors for both <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="228064043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064043">(Feb 27 2021 at 15:16)</a>:</h4>
<p>At this point I'm happy with a post-mono error, it's better than an LLVM assert.</p>



<a name="228064067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064067">(Feb 27 2021 at 15:17)</a>:</h4>
<p>Previously we were doing this with huge <code>match</code> statements, but it gets tricky where there are 64k possible values.</p>



<a name="228064140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064140">(Feb 27 2021 at 15:18)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Between1And7</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">i32</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">IsTrue</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">IsTrue</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="mi">1</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">IsTrue</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="mi">2</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">IsTrue</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="mi">3</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">IsTrue</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">IsTrue</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="mi">5</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">IsTrue</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="mi">6</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="w"> </span><span class="n">IsTrue</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="mi">7</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">i32</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span>: <span class="nc">IsTrue</span><span class="w"></span>
<span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">1</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">8</span><span class="o">&gt;</span><span class="p">();</span><span class="w"> </span><span class="c1">// error</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228064150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064150">(Feb 27 2021 at 15:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228064039">said</a>:</p>
<blockquote>
<p>imo we should prevent post-mono errors for both <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>
</blockquote>
<p>I agree that would be nice, but I expect the system required to achieve this to be so unwieldy that the cure is worse than the disease. ;) but time will tell I guess; we'll see what the system looks like when you got it figured out. I am jut worried about blocking <code>const</code> blocks that use generics on that...</p>



<a name="228064289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064289">(Feb 27 2021 at 15:21)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> that's the pre-mono variant, right?</p>



<a name="228064293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064293">(Feb 27 2021 at 15:21)</a>:</h4>
<p>(playing around with a post-mono version based on assoc consts that avoids having to list all the cases)</p>



<a name="228064295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064295">(Feb 27 2021 at 15:21)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> why doesn't this error? <span aria-label="shock" class="emoji emoji-1f628" role="img" title="shock">:shock:</span> </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Between1And7</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">i32</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">i32</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Between1And7</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">CHECK</span>: <span class="p">()</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="mi">7</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">N</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">i32</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Between1And7</span>::<span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span>::<span class="n">CHECK</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">1</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">8</span><span class="o">&gt;</span><span class="p">();</span><span class="w"> </span><span class="c1">// error</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228064355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064355">(Feb 27 2021 at 15:22)</a>:</h4>
<p>wait, what am I missing here <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="228064362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064362">(Feb 27 2021 at 15:22)</a>:</h4>
<p>It gets turned into a runtime assert?</p>



<a name="228064364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064364">(Feb 27 2021 at 15:22)</a>:</h4>
<p>no, it just runs successfully</p>



<a name="228064390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064390">(Feb 27 2021 at 15:23)</a>:</h4>
<p>oooo</p>



<a name="228064391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064391">(Feb 27 2021 at 15:23)</a>:</h4>
<p>we're using <code>i32</code></p>



<a name="228064393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064393">(Feb 27 2021 at 15:23)</a>:</h4>
<p>of course it doesn't cause an error</p>



<a name="228064394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064394">(Feb 27 2021 at 15:23)</a>:</h4>
<p><span aria-label="cry" class="emoji emoji-1f622" role="img" title="cry">:cry:</span></p>



<a name="228064529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064529">(Feb 27 2021 at 15:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228064293">said</a>:</p>
<blockquote>
<p>(playing around with a post-mono version based on assoc consts that avoids having to list all the cases)</p>
</blockquote>
<p>this works</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_panic)]</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">ValidInt</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Valid</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">VALID</span>: <span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Valid</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">ValidInt</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">VALID</span>: <span class="p">()</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">8</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* valid */</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="fm">panic!</span><span class="p">(</span><span class="s">"not valid"</span><span class="p">);</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ValidInt</span>::<span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span>::<span class="n">VALID</span><span class="p">;</span><span class="w"> </span><span class="c1">// Make sure it is valid</span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">0</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="c1">//foo::&lt;8&gt;(); // leads to error</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>(there are stable alternatives to panicking, like <code>1/0</code>). the error msg is quite bad though -- it points to inside <code>foo</code>, not to its call site. (but fixing this could be hard I think.)</p>



<a name="228064549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064549">(Feb 27 2021 at 15:26)</a>:</h4>
<p>oh you don't need a trait to use assoc consts? that helps^^</p>



<a name="228064573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064573">(Feb 27 2021 at 15:26)</a>:</h4>
<p>yeah, i thought about using array indexing with <code>[(); 1][!check as usize]</code></p>



<a name="228064620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064620">(Feb 27 2021 at 15:27)</a>:</h4>
<p>doesn't this only lint though?</p>



<a name="228064623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064623">(Feb 27 2021 at 15:27)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">ValidInt</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">ValidInt</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[allow(unconditional_panic)]</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">VALID</span>: <span class="p">()</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="mi">8</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* valid */</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="o">/</span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ValidInt</span>::<span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span>::<span class="n">VALID</span><span class="p">;</span><span class="w"> </span><span class="c1">// Make sure it is valid</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228064629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064629">(Feb 27 2021 at 15:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228064620">said</a>:</p>
<blockquote>
<p>doesn't this only lint though?</p>
</blockquote>
<p>even if you allow the lint it should still hard-error during codegen</p>



<a name="228064630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064630">(Feb 27 2021 at 15:27)</a>:</h4>
<p>yeah it does ^^</p>



<a name="228064634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064634">(Feb 27 2021 at 15:28)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=3589a02bee03631632d49cd04df8d56d">yeah it does</a></p>



<a name="228064639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064639">(Feb 27 2021 at 15:28)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: erroneous constant encountered
  --&gt; src/main.rs:12:13
   |
12 |     let _ = Between1And7::&lt;N&gt;::CHECK;
   |             ^^^^^^^^^^^^^^^^^^^^^^^^
</code></pre></div>
<p>with the good error <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="228064684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064684">(Feb 27 2021 at 15:28)</a>:</h4>
<p>well, not really</p>



<a name="228064688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064688">(Feb 27 2021 at 15:28)</a>:</h4>
<p>(not like we can do much better here if they silence the lint)</p>



<a name="228064697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064697">(Feb 27 2021 at 15:28)</a>:</h4>
<p>it doesnt show where <code>foo</code> gets called with the bad param^^</p>



<a name="228064721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064721">(Feb 27 2021 at 15:29)</a>:</h4>
<p>Is the lint controlled from the caller side or callee side?</p>



<a name="228064730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064730">(Feb 27 2021 at 15:29)</a>:</h4>
<p>i think the crate currently getting compiled <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="228064732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064732">(Feb 27 2021 at 15:29)</a>:</h4>
<p>don't know which hirId we use though</p>



<a name="228064736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064736">(Feb 27 2021 at 15:29)</a>:</h4>
<p>as the lint source</p>



<a name="228064787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064787">(Feb 27 2021 at 15:30)</a>:</h4>
<p>yeah OOB <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=77fb7553ce22574fefce546ab10964ef">also works</a> and you can hack some more information into the error that way^^</p>



<a name="228064845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228064845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228064845">(Feb 27 2021 at 15:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228064736">said</a>:</p>
<blockquote>
<p>as the lint source</p>
</blockquote>
<p>no idea, I never understood the CTFE error reporting code...</p>



<a name="228065052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065052">(Feb 27 2021 at 15:34)</a>:</h4>
<p>What are the chances <code>const_evaluatable_checked</code> breaks horribly if I just enable it for <code>stdarch</code>?</p>



<a name="228065069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065069">(Feb 27 2021 at 15:35)</a>:</h4>
<p>100%</p>



<a name="228065073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065073">(Feb 27 2021 at 15:35)</a>:</h4>
<p>leaking const evaluatable predicates to other crates</p>



<a name="228065076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065076">(Feb 27 2021 at 15:35)</a>:</h4>
<p>causes an ice rn</p>



<a name="228065080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065080">(Feb 27 2021 at 15:35)</a>:</h4>
<p>activating the feature together with incremental compilation</p>



<a name="228065085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065085">(Feb 27 2021 at 15:35)</a>:</h4>
<p>causes an ice rn</p>



<a name="228065087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065087">(Feb 27 2021 at 15:35)</a>:</h4>
<p><span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="228065281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065281">(Feb 27 2021 at 15:39)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228065073">said</a>:</p>
<blockquote>
<p>leaking const evaluatable predicates to other crates</p>
</blockquote>
<p>if the other crate is not also using <code>const_evaluatable_checked</code></p>



<a name="228065467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065467">(Feb 27 2021 at 15:43)</a>:</h4>
<p>Here's what I got so far:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="fm">macro_rules!</span><span class="w"> </span><span class="n">static_assert</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$imm</span>:<span class="nc">ident</span><span class="w"> </span>: <span class="cp">$ty</span>:<span class="nc">ty</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="cp">$e</span>:<span class="nc">expr</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">struct</span> <span class="nc">ValidInt</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="cp">$imm</span>: <span class="cp">$ty</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="k">trait</span><span class="w"> </span><span class="n">Valid</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">const</span><span class="w"> </span><span class="n">VALID</span>: <span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="cp">$imm</span>: <span class="cp">$ty</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Valid</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">ValidInt</span><span class="o">&lt;</span><span class="cp">$imm</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">const</span><span class="w"> </span><span class="n">VALID</span>: <span class="p">()</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="cp">$e</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="p">);</span><span class="w"></span>
<span class="w">            </span><span class="p">};</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ValidInt</span>::<span class="o">&lt;</span><span class="cp">$imm</span><span class="o">&gt;</span>::<span class="n">VALID</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228065663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065663">(Feb 27 2021 at 15:46)</a>:</h4>
<p>Seems to work! Thanks!</p>



<a name="228065746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065746">(Feb 27 2021 at 15:48)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span>  as <span class="user-mention" data-user-id="216206">@lcnr</span> demonstrated you can just use <code>impl&lt;const $imm: $ty&gt; for ValidInt&lt;$imm&gt; {</code>, then you don't need the <code>trait</code></p>



<a name="228065881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228065881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228065881">(Feb 27 2021 at 15:51)</a>:</h4>
<p>Indeed!</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="fm">macro_rules!</span><span class="w"> </span><span class="n">static_assert</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$imm</span>:<span class="nc">ident</span><span class="w"> </span>: <span class="cp">$ty</span>:<span class="nc">ty</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="cp">$e</span>:<span class="nc">expr</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">struct</span> <span class="nc">Validate</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="cp">$imm</span>: <span class="cp">$ty</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="cp">$imm</span>: <span class="cp">$ty</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Validate</span><span class="o">&lt;</span><span class="cp">$imm</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">const</span><span class="w"> </span><span class="n">VALID</span>: <span class="p">()</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="p">(</span><span class="cp">$e</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="p">);</span><span class="w"></span>
<span class="w">            </span><span class="p">};</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Validate</span>::<span class="o">&lt;</span><span class="cp">$imm</span><span class="o">&gt;</span>::<span class="n">VALID</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228067093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228067093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228067093">(Feb 27 2021 at 16:12)</a>:</h4>
<p>Wow I had not realized that <code>rustc_legacy_const_generics</code> is already implemented; thanks a ton <span class="user-mention" data-user-id="143274">@Amanieu</span> for pushing this forward. :)</p>



<a name="228067462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228067462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228067462">(Feb 27 2021 at 16:19)</a>:</h4>
<p>At the moment only 2 functions in stdarch are actually using it though.</p>



<a name="228067514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228067514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228067514">(Feb 27 2021 at 16:20)</a>:</h4>
<p>There's about 1200 functions using <code>rustc_args_required_const</code>.</p>



<a name="228068302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228068302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228068302">(Feb 27 2021 at 16:34)</a>:</h4>
<p>sure, but still, baby steps :)</p>



<a name="228069020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228069020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228069020">(Feb 27 2021 at 16:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228067093">said</a>:</p>
<blockquote>
<p>Wow I had not realized that <code>rustc_legacy_const_generics</code> is already implemented; thanks a ton <span class="user-mention silent" data-user-id="143274">Amanieu</span> for pushing this forward. :)</p>
</blockquote>
<p>oh nice, that's awesome <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="228069986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228069986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228069986">(Feb 27 2021 at 17:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="143274">Amanieu</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228067462">said</a>:</p>
<blockquote>
<p>At the moment only 2 functions in stdarch are actually using it though.</p>
</blockquote>
<p>Does that mean that stdarch is generally open for further conversion to <code>rustc_legacy_const_generics</code>?</p>



<a name="228072194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228072194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228072194">(Feb 27 2021 at 17:43)</a>:</h4>
<p>should be fine to make PRs</p>



<a name="228074643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228074643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228074643">(Feb 27 2021 at 18:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="352985">tm</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/228069986">said</a>:</p>
<blockquote>
<p>Does that mean that stdarch is generally open for further conversion to <code>rustc_legacy_const_generics</code>?</p>
</blockquote>
<p>Yep! PRs are welcome. I'm going to create a tracking issue with instructions for converting functions to the new style.</p>



<a name="228074808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228074808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228074808">(Feb 27 2021 at 18:32)</a>:</h4>
<p>This is technically a breaking change, right? Generic parameters cannot be used, or can they?</p>



<a name="228074976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228074976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228074976">(Feb 27 2021 at 18:35)</a>:</h4>
<p>yeah, this is a theoretically breaking change</p>



<a name="228074986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228074986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228074986">(Feb 27 2021 at 18:36)</a>:</h4>
<p>i don't expect it to actually break  anything though</p>



<a name="228075523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228075523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228075523">(Feb 27 2021 at 18:45)</a>:</h4>
<p>Yes it is technically breaking.</p>



<a name="228075572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228075572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228075572">(Feb 27 2021 at 18:46)</a>:</h4>
<p>Unfortunately there's no way to know for sure until we run it past crater.</p>



<a name="228080643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228080643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228080643">(Feb 27 2021 at 20:21)</a>:</h4>
<p>I thought that rustc would automatically "rewrite" the old style to the new style?</p>



<a name="228080877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228080877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228080877">(Feb 27 2021 at 20:25)</a>:</h4>
<p>yeah it does, but consts in the body of a fn cannot refer to generic params of the fn</p>



<a name="228080960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228080960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228080960">(Feb 27 2021 at 20:26)</a>:</h4>
<p>mmmm... but they will be able to some day right?</p>



<a name="228081346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228081346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228081346">(Feb 27 2021 at 20:33)</a>:</h4>
<p>yeah I sure hope so. we talked about "generic consts" for forever... long enough that in the beginning I kept mixing that up with "const generics"^^</p>



<a name="228081362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228081362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228081362">(Feb 27 2021 at 20:33)</a>:</h4>
<p>we actually kind of already have generic consts but not exposed in nice ways... promoteds can be generic. and associated consts.</p>



<a name="228090261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228090261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228090261">(Feb 27 2021 at 23:30)</a>:</h4>
<p><span class="user-mention" data-user-id="222471">@BurntSushi</span></p>



<a name="228939902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228939902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228939902">(Mar 05 2021 at 11:47)</a>:</h4>
<p>The assertion failure diagnostic are rather unhelpful in diagnosing the source of the error (<a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=6dd3e7d02d995ab5aaa34af691e2eab7">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=6dd3e7d02d995ab5aaa34af691e2eab7</a>). Is there something we can do to improve this now, or is it blocked on turning const_err into a hard error?</p>



<a name="228948421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228948421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228948421">(Mar 05 2021 at 13:00)</a>:</h4>
<p>Hmm, I wonder if we should put <code>#[allow(const_err)]</code> on the validation constant, then error message at least hints at <code>-Z macro-backtrace</code>, which can help pinpoint the issue.</p>



<a name="228949933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228949933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228949933">(Mar 05 2021 at 13:10)</a>:</h4>
<p><code>#[allow(const_err]</code> at least shows where the error happens so it would be useful for stdarch; however last time I tried with <code>-Z macro-backtrace</code> it didn't add much more information IIRC ?</p>



<a name="228952483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228952483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228952483">(Mar 05 2021 at 13:28)</a>:</h4>
<p>Testing again, right macro-backtrace doesn't add much in this case. Which is even better since no nightly features are required!</p>



<a name="228959924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228959924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228959924">(Mar 05 2021 at 14:14)</a>:</h4>
<p>The <code>#[allow(const_err)]</code> doesn't help in cross-crate errors, so any suggestion would still be appreciated!</p>



<a name="228994535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228994535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228994535">(Mar 05 2021 at 17:44)</a>:</h4>
<p>Yeah the errors are bad and making <code>const_err</code> a hard error doesn't really help...</p>



<a name="228994572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228994572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228994572">(Mar 05 2021 at 17:45)</a>:</h4>
<p>the problem is that the error is emitted by the CTFE query, which has no idea where that constant is being used, so it can't point to that span</p>



<a name="228994590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228994590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228994590">(Mar 05 2021 at 17:45)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> ^</p>



<a name="228995189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/228995189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#228995189">(Mar 05 2021 at 17:49)</a>:</h4>
<p>should we experiment with returning the actual error from the query and requiring it to be reported outside?</p>



<a name="229002532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229002532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229002532">(Mar 05 2021 at 18:35)</a>:</h4>
<p>but then how do we avoid duplicate errors?</p>



<a name="229004517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229004517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229004517">(Mar 05 2021 at 18:48)</a>:</h4>
<p>well... we already avoid duplicate errors if they are exactly the same</p>



<a name="229004526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229004526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229004526">(Mar 05 2021 at 18:48)</a>:</h4>
<p>that is just a compiler thing</p>



<a name="229004558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229004558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229004558">(Mar 05 2021 at 18:49)</a>:</h4>
<p>and in the case we report them on different sites, then we do want them duplicated</p>



<a name="229087847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229087847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229087847">(Mar 06 2021 at 10:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/229004558">said</a>:</p>
<blockquote>
<p>and in the case we report them on different sites, then we do want them duplicated</p>
</blockquote>
<p>do we? I imagine we're showing an error with a kind of stacktrace, i.e., several spans attached to the same error. the "root frame" will be different but all the rest will be the same when a failing const is used in multiple places.</p>



<a name="229095897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229095897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229095897">(Mar 06 2021 at 12:59)</a>:</h4>
<p>well... we could achieve that by keeping the report at the site it is now, but also return the span. Then the caller, when emitting their own error, can at least add a note saying where the error came from.</p>



<a name="229097101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229097101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229097101">(Mar 06 2021 at 13:14)</a>:</h4>
<p>I dont think I understand what that would look like</p>



<a name="229097422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229097422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229097422">(Mar 06 2021 at 13:19)</a>:</h4>
<p>Right now our errors look like</p>
<div class="codehilite"><pre><span></span><code>warning: any use of this value will cause an error
 --&gt; src/main.rs:3:18
  |
3 | const FOO: i32 = 1/0;
  | -----------------^^^-
  |                  |
  |                  attempt to divide `1_i32` by zero
  |
note: the lint level is defined here
 --&gt; src/main.rs:1:8
  |
1 | #[warn(const_err)]
  |        ^^^^^^^^^

error[E0080]: erroneous constant used
 --&gt; src/main.rs:6:13
  |
6 |     let x = FOO;
  |             ^^^ referenced constant has errors
</code></pre></div>
<p>and I would expect that we don't change the first error, but change the second error to have an additional note</p>
<div class="codehilite"><pre><span></span><code>error[E0080]: erroneous constant used
 --&gt; src/main.rs:6:13
  |
6 |     let x = FOO;
  |             ^^^ referenced constant has errors
note: constant defined here
 --&gt; src/main.rs:3:18
  |
3 | const FOO: i32 = 1/0;
  |       ^^^
</code></pre></div>



<a name="229102867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229102867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229102867">(Mar 06 2021 at 14:39)</a>:</h4>
<p>hm... but those two errors could be quite far apart from each other in the error log</p>



<a name="229109681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229109681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229109681">(Mar 06 2021 at 16:19)</a>:</h4>
<p>I'm not sure what else to do. Either we repeat everything, or we don't. If you have any suggestions on how it should look I'm all ears</p>



<a name="229109938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229109938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229109938">(Mar 06 2021 at 16:22)</a>:</h4>
<p>well ideally there'd be a single error with a "backtrace" that contains both the const and where it is used (and, with const generics, perhaps even further up the causal chain of monomorphizations) -- but we only do that once per error, not for each use.</p>



<a name="229109939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229109939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229109939">(Mar 06 2021 at 16:22)</a>:</h4>
<p>I have no idea how to achieve that, though.^^</p>



<a name="229120880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229120880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229120880">(Mar 06 2021 at 19:05)</a>:</h4>
<p><span class="user-mention" data-user-id="220273">@Jane Lusby</span> ??</p>



<a name="229180443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229180443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229180443">(Mar 07 2021 at 11:32)</a>:</h4>
<p>so... the follow up uses of the error would just not emit an error at all? Or at least not one with the whole backtrace?</p>



<a name="229180707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229180707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229180707">(Mar 07 2021 at 11:36)</a>:</h4>
<p>I guess we could implement something similar to <code>Steal</code>, but only for diagnostics. Basically the first time you steal it, you get a full error, and then the error replaces itself with  a dummy error. We would make this kind of stealable diagnostic be completely transparent to the query system (hash/eq just always return the same value/true)</p>



<a name="229180713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229180713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229180713">(Mar 07 2021 at 11:37)</a>:</h4>
<p>I think that would be safe in the current query system</p>



<a name="229180730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229180730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229180730">(Mar 07 2021 at 11:37)</a>:</h4>
<p>we'd just need to MCP it</p>



<a name="229180893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229180893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229180893">(Mar 07 2021 at 11:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/static_assert.20for.20const.20generics/near/229180443">said</a>:</p>
<blockquote>
<p>so... the follow up uses of the error would just not emit an error at all? Or at least not one with the whole backtrace?</p>
</blockquote>
<p>yeah something like that</p>



<a name="229180939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229180939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229180939">(Mar 07 2021 at 11:41)</a>:</h4>
<p>I cannot comment on the implementation details. ;) but this seems like something where we should get some consesus on the desired outcome before starting implementation work.</p>



<a name="229180963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229180963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229180963">(Mar 07 2021 at 11:41)</a>:</h4>
<p>the implementation work was always what was blocking the possible nice diagnostics we could have</p>



<a name="229181024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/static_assert%20for%20const%20generics/near/229181024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/static_assert.20for.20const.20generics.html#229181024">(Mar 07 2021 at 11:42)</a>:</h4>
<p>I'll start a new topic in <a class="stream" data-stream-id="147480" href="/#narrow/stream/147480-t-compiler.2Fwg-diagnostics">#t-compiler/wg-diagnostics</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>